package com.yysjyr.logisticssystem.workbench.service.impl;

import com.yysjyr.logisticssystem.workbench.entity.Order;
import com.yysjyr.logisticssystem.workbench.mapper.OrderMapper;
import com.yysjyr.logisticssystem.workbench.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service
@Transactional
public class OrderServiceImpl implements OrderService {

    @Autowired
    private OrderMapper orderMapper;

    /**
     * @author: 吃货大人
     * @date: 2023/10/26
     * @time : 16:09
     * @param order
     * @return : 新增的订单条数
     * @description: 新增订单
     */
    @Override
    public int saveCreateOrder(Order order) {
        return orderMapper.insertOrder(order);
    }

    /**
     * @author: 吃货大人
     * @date: 2023/10/26
     * @time : 16:21
     * @param orders 订单对象集合
     * @return : 新增的条数
     * @description: 根据对象集合进行新增订单
     */
    @Override
    public int saveCreateOrder(List<Order> orders){
        return orderMapper.insertOrderList(orders);
    }

    /**
     * @author: 吃货大人
     * @date: 2023/10/27
     * @time : 8:28
     * @param
     * @return :
     * @description:根据id查询订单
     */
    @Override
    public Order queryOrderById(String id) {
        return orderMapper.selectOrderById(id);
    }

    /**
     * @author: 吃货大人
     * @date: 2023/10/27
     * @time : 8:29
     * @param
     * @return :
     * @description: 查询所有订单
     */
    @Override
    public List<Order> queryOrderList() {
        return orderMapper.selectAllOrder();
    }

    /**
     * @author: 吃货大人
     * @date: 2023/10/27
     * @time : 8:29
     * @param
     * @return :
     * @description:根据id查询订单 详情
     */
    @Override
    public Map<String, String> queryOrderDetailById(String id) {
        return orderMapper.selectOrderDetailById(id);
    }

    /**
     * @author: 吃货大人
     * @date: 2023/10/27
     * @time : 8:30
     * @param
     * @return :
     * @description:查询所有订单详细
     */
    @Override
    public List<Map<String,String>> queryOrderDetailList(){
        return orderMapper.selectAllOrderDetail();
    }
}
